    //
//  AuthorViewController.m
//  TuiTe
//
//  Created by vhly on 10-9-8.
//  Copyright 2010 xhzhang. All rights reserved.
//

#import "AuthorViewController.h"


@implementation AuthorViewController

@synthesize web;
@synthesize authURL;

/*
 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
        // Custom initialization
    }
    return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
	self.navigationItem.title = @"Authorize TuiTe";
}

- (void)viewDidAppear:(BOOL)animated{
	[super viewDidAppear:animated];
	if (self.authURL) {
		NSString *au = [[NSString alloc] initWithFormat:@"http://vhlyserver.appspot.com/pr?eu=%@",self.authURL];
		NSURL *url = [[NSURL alloc] initWithString:au];
		NSMutableURLRequest *req = [[NSMutableURLRequest alloc] initWithURL:url];
		[req setTimeoutInterval:3000];
		[req addValue:@"TuiTe/1.0 iPhone" forHTTPHeaderField:@"User-Agent"];
		NSURLResponse *resp = nil;
		NSError *err = nil;
		NSData *dt = [NSURLConnection sendSynchronousRequest:req returningResponse:&resp error:&err];
		[req release];
		[url release];
		[au release];
		if (dt) {
			NSString *str = [[NSString alloc] initWithData:dt encoding:NSUTF8StringEncoding];
			NSLog(str);
			[str release];
			if (resp) {
				[resp release];
			}
		}else{
			if (err) {
				[err release];
			}
		}

	}
}

/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
	[web release];
	[authURL release];
    [super dealloc];
}


@end
